﻿#define _CRT_SECURE_NO_WARNINGS
​
#include<stdio.h>
#include<string.h>
void deal1_with(char* arr, int len) {
    int left = 0;
    int right = len - 1;
    while (left <= right) {
        char tmp = *(arr + left);
        *(arr + left) = *(arr + right);
        *(arr + right) = tmp;
        left++;
        right--;
    }
}
void deal2_with(char* arr) {
    int count = 0;
    //再将每个单词逆序
    char* p = arr;
    while ((*p) != '\0') {
        if ((*p) != ' ') {
            count++;
            p++;
        }
        if ((*p) == ' ' || (*p) == '\0') {
            deal1_with(p - count, count);
            count = 0;
            p++;
        }
    }
}
int main() {
    char arr[103] = { 0 };
    gets(arr);
    int len = strlen(arr);
    //先将所有字符串逆序
    deal1_with(arr, len);
    //再对单词进行逆序
    deal2_with(arr);
    puts(arr);
    return 0;
}
